﻿using System;
using Microsoft.Xna.Framework;

namespace ProjetCom.Model.Template
{
    public abstract class Element
    {
        protected double m_x;
        protected double m_y;
        protected String m_name;
        public const int Width = 64;
        public const int Height = 64;
        private Boolean m_IsAlive;
            
        public Point Centre
        {
            get { return new Point((int)(m_x - Width / 2), (int)(m_y - Width / 2)); }
        }

        public enum CoteCollision{right, left, top, bottom, none, };

        virtual public Boolean IsMoove
        {
            get { return false; }
        }

        public Rectangle Rectangle
        {
            get { return new Rectangle((int)this.X, (int)this.Y, Element.Width, Element.Height); }
        }

        virtual public Boolean IsAlive
        {
            get { return m_IsAlive; }
            protected set { m_IsAlive = value; }
        }


        public double X
        {
            get { return m_x; }
            set { m_x = value; }
        }

        public double Y
        {
            get { return m_y; }
            set { m_y = value; }
        }

        public String Name
        {
            get { return m_name; }
        }

        public Element(int p_x, int p_y)
        {
            m_x = p_x * Width;
            m_y = p_y * Height;
            m_IsAlive = true;
        }


        abstract public void Update(Microsoft.Xna.Framework.GameTime _gameTime);

        public Boolean IsCrashed(Element p_other)
        {
            return false; // todo
        }

        abstract public CoteCollision EnterCollision(Element Other);

        public void Collision(CoteCollision p_cote) 
        {
            Collision(p_cote, false);
        }
        abstract public void Collision(CoteCollision p_cote, Boolean p_moove);
    }
}
